<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>新增报表——柱状图</title>
    <!-- 引入 echarts.js -->
    <script src="/static/js/plugins/echart/echarts.min.js"></script>
</head>
<body>
<!-- 为 ECharts 准备一个具备大小（宽高）的 DOM -->
<div id="main" style="width: 500px;height:460px;"></div>

<script type="text/javascript">
    // 基于准备好的dom，初始化echarts实例
    var myChart = echarts.init(document.getElementById("main"));

    // 指定图表的配置项和数据
    var option = {
        title: {
            text: ${title},//图表标题
            subtext: '单位:个',//副标题
            left: "center"//对其方式
        },
        tooltip: {
            trigger: 'axis'
        },
        legend: {
            data: [''],//数据值的含义
            left: "left"
        },
        toolbox: {
            show: true,
            feature: {
                dataView: {show: true, readOnly: true},
                magicType: {show: true, type: ['line', 'bar']},
                restore: {show: true},
                saveAsImage: {show: true}
            }
        },
        calculable: true,
        xAxis: [
            {
                type: 'category',
                data: ${x} //X轴显示的数据 ["x","y","z"]
            }
        ],
        yAxis: [
            {
                type: 'value',
                min: 0,
                minInterval: 1
            }
        ],
        series: [
            {
                name: ${series},
                type: 'bar',
                barMaxWidth: '50',
                data: ${y},//Y轴显示的数值 [10,20,30]
                markPoint: {
                    data: [
                        {type: 'max', name: '最大值'},
                        {type: 'min', name: '最小值'}
                    ]
                },
                markLine: {
                    data: [
                        {type: 'average', name: '平均值'}
                    ]
                }
            }
        ]
    };

    // 使用刚指定的配置项和数据显示图表。
    myChart.setOption(option);
    // 根据窗口大小调整图表
    window.onresize = myChart.resize;
</script>
</body>
</html>
